Studentportal::Application.routes.draw do

  get "portal/", :controller => 'frontend/portal', :action => 'index'
  post "portal/dologin", :to => "frontend::portal#dologin"
  match "portal/register" => "frontend::portal#register", :via => [:get, :post]
  match "portal/updateprofile/(:user_id)", :controller => "frontend/portal", :action => "updateprofile", :via => [:get, :post]
  match "portal/info", :controller => 'frontend/portal', :action => 'info', :via => [:get, :post]
  match "portal/forgotpass", :controller => 'frontend/portal', :action => 'forgotpass', :via => [:get, :post]
  match "portal/resetpassword/(:login)/(:key)", :controller => 'frontend/portal', :action => 'resetpassword', :via => [:get, :post]
  match "portal/access_denied", :controller => 'frontend/portal', :action => 'access_denied'
  get "portal/index", :to => "frontend::portal#index"
  get "portal/logout", :controller => 'frontend/portal', :action => 'logout'

  #frontend activity
  get "activity/", :controller => 'frontend/activity', :action => 'index'
  get "activity/index", :controller => 'frontend/activity', :action => 'index'
  match "activity/new/(:type)", :controller => "frontend/activity", :action => "new", :via => [:get, :post]
  match "activity/edit/(:type)", :to => "frontend::activity#edit", :via => [:get, :post]
  match "activity/delete/(:type)", :to => "frontend::activity#delete", :via => [:get, :post]
  match "activity/show/(:type)/(:id)", :to => "frontend::activity#show", :via => [:get, :post]
  match "activity/show/(:id)", :to => "frontend::activity#show", :via => [:get, :post]

  #frontend library
  match "library/", :controller => "frontend/library", :action => "index", :via => [:get, :post]
  match "library/borrowlist/(:user_id)", :controller => "frontend/library", :action => "borrowlist", :via => [:get, :post]
  match "library/view/(:document_id)", :controller => "frontend/library", :action => "view", :via => [:get, :post]

  #backend routes
  match "admin/", :controller => "backend/dashboard", :action => "index", :via => [:get, :post]
  match "admin/user", :controller => "backend/user", :action => "index", :via => [:get, :post]
  match "admin/user/view/(:user_id)", :controller => "backend/user", :action => "view", :via => [:get, :post]
  match "admin/user/edit/(:user_id)", :controller => "backend/user", :action => "edit", :via => [:get, :post]
  match "admin/user/delete/(:user_id)", :controller => "backend/user", :action => "delete", :via => [:get, :post]
  # library manage
  match "admin/library", :controller => "backend/library", :action => "index", :via => [:get, :post]
  match "admin/library/new", :controller => "backend/library", :action => "new", :via => [:get, :post]
  match "admin/library/edit/(:document_id)", :controller => "backend/library", :action => "edit", :via => [:get, :post]
  match "admin/library/view/(:document_id)", :controller => "backend/library", :action => "view", :via => [:get, :post]
  match "admin/library/delete/(:document_id)", :controller => "backend/library", :action => "delete", :via => [:get, :post]
  match "admin/library/lend/(:document_id)", :controller => "backend/library", :action => "lend", :via => [:get, :post]
  match "admin/library/lend_document/", :controller => "backend/library", :action => "lend_document", :via => [:get, :post]
  match "admin/library/lend_detail/(:document_id)", :controller => "backend/library", :action => "lend", :via => [:get, :post]
  match "admin/library/borrowlist/(:document_id)/(:user_id)", :controller => "backend/library", :action => "borrowlist", :via => [:get,:post]
  match "admin/library/user_borrow_list/(:user_id)", :controller => "backend/library", :action => "user_borrow_list", :via => [:get,:post]
  match "admin/library/return/(:document_id)/(:record_id)", :controller => "backend/library", :action => "return", :via => [:get, :post]
  match "admin/library/return_document/", :controller => "backend/library", :action => "return_document", :via => [:get, :post]
  match "admin/library/delete_borrow_record/(:document_id)/(:record_id)", :controller => "backend/library", :action => "delete_borrow_record", :via => [:get,:post]
  #API
  match "api/student/search/(:key)", :controller => "api/student", :action => "search", :via => [:get, :post]
  match "api/student/(:id)", :controller => "api/student", :action => "info", :via => [:get, :post]

  #activities restful resource
  resource :student_activities, :path => "activity/new"

  #root
  root :to => 'frontend::portal#index'


end
